#include<cstdio>
#include<iostream>
using namespace std;
#define int long long 
#define fread(x) ios::sync_with_stdio(x)

int bitsum(int x){
	int sum = 1;
	while(x > 0){
		if(x % 10){
		sum *= x % 10;
		}
		x /= 10;
	}
	return sum;
}

signed main(){
	fread(0);
	int n;
	cin >> n;
	
//	cout<< bitsum(123456789);	
//	cout<< bitsum(24);
	while(n >= 10){
		n = bitsum(n);
		cout << n ;
		if(n >= 10) cout<<endl;
	}
	return 0;
}
